import React, { useContext } from 'react';
import { connect, ReactReduxContext } from 'react-redux';
import { OtherContext } from '../contexts';

class ClassChild extends React.PureComponent {
  static contextType = OtherContext;
  constructor(props, context) {
    super(props, context);
    console.log('newContext', context)
    // this.state = {
    //   newTestP: context.testP,
    // }
  }

  // componentDidMount() {
  //   this.unSubscribeRedux = this.context.store.subscribe(() => {
  //     this.setState({ newTestP: this.context.store.getState().testP });
  //   })
  // }

  // componentWillUnmount() {
  //   if (this.unSubscribeRedux) {
  //     this.unSubscribeRedux();
  //   }
  // }

  render() {
    console.log('ClassChild render');
    return <div>test</div>
    // return <ReactReduxContext.Consumer>
    //   {value => {
    //     console.log(value.store)
    //     return <div>{value.store.getState().testP}</div>
    //   }}
    // </ReactReduxContext.Consumer>
  }
}
export default ClassChild
// export default connect(state => state, null, null, { pure: false })(ClassChild)